package cn.momoshenchi.search.controller;

import cn.momoshenchi.search.entity.R;
import cn.momoshenchi.search.entity.SkuEsModel;
import cn.momoshenchi.search.service.ProductSaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

/**
 * @version : 1.0
 * @author: momoshenchi
 * @date: 2021/5/6 - 19:23
 */
@RequestMapping("/search")
@RestController
public class SaveController
{

    @Autowired
    private ProductSaveService productSaveService;


    @PostMapping("/save/product")
    public R productSave(@RequestBody List<SkuEsModel> skuEsModels)
    {
        try
        {
            productSaveService.saveUp(skuEsModels);
        }
        catch (IOException e)
        {
            e.printStackTrace();
            return R.error();
        }
        return  R.ok();
    }

}
